<!DOCTYPE html>
<html lang="en">

	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
		<meta name="description" content="">
		<meta name="author" content="">
		<!-- STYLESHEETS -->
		<!--[if lt IE 9]><script src="../../js/flot/excanvas.min.js"></script><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
		<link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css">
		<link rel="stylesheet" type="text/css" href="../../css/themes/default.css" id="skin-switcher">
		<link rel="stylesheet" type="text/css" href="../../css/responsive.css">
				<link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
		<!-- file-input -->
		<link rel="stylesheet" type="text/css" href="../../js/file-input/fileinput.css" />
		<!-- datatable -->
		<link rel="stylesheet" href="../../js/datatables/datatable.css">
		<!-- WIZARD -->
		<link rel="stylesheet" type="text/css" href="../../js/bootstrap-wizard/wizard.css" />

	</head>

	<body>
		<header class="navbar clearfix" id="header">
		</header>

		<!-- PAGE -->
		<section id="page">
			<!-- SIDEBAR -->
			<div id="sidebar" class="sidebar">
			<div class="sidebar-menu nav-collapse">
						
						<!-- SIDEBAR MENU -->
						<ul>							
							
							
						</ul>
						<!-- /SIDEBAR MENU -->
					</div>

			</div>
			<!-- /SIDEBAR -->
			<div id="main-content">
			
				<div class="container">
					<div class="row">
						<div id="content" class="col-lg-12">
							<!-- PAGE HEADER-->
							<div class="row">
								<div class="col-sm-12">
									<div class="page-header">
										<!-- STYLER -->

										<!-- /STYLER -->
										<!-- BREADCRUMBS -->
										<ul class="breadcrumb">
											<li>
												<i class="fa fa-home"></i>
												<a href="index.html">首页</a>
											</li>
											<li>
												<a href="#">订单管理</a>
											</li>
											<li>订单详情</li>
										</ul>
										<!-- /BREADCRUMBS -->

									</div>
								</div>
							</div>
							<!-- /PAGE HEADER -->
							<!-- SAMPLE -->

							<div class="row">
								<div class="col-md-12" style="background-color:#ffffff">
									<div class="box" style="margin-top:10px">
										<div class="box-title" style="border-bottom:1px solid #5e87b0;line-height:38px">
											<h4><i class="fa fa-file" style="color:red"></i>申请信息</h4>
											<a class="btn btn-default" href="agent_list.html" style="float:right">返回代理列表</a>
										</div>
										<div class="box-body">
											<div class="form-group  mrg-bt10">
											  <label class="control-label col-md-4 " >申请时间：</label>
												<div class="col-md-6 inline" id="createTime">
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 " >状态：</label>
												<div class="col-md-6 inline" id="checkStatus">
												</div>
												</div>
												<div class="form-group  mrg-bt10 div_result">
												<label class="control-label col-md-4 " >审核时间：</label>
												<div class="col-md-6 inline" id="checkTime">
												</div>
												</div>
												<div class="form-group  mrg-bt10 div_result">
												<label class="control-label col-md-4 " >审核人：</label>
												<div class="col-md-6 inline" id="checkBy">
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 " >用户账号：</label>
												<div class="col-md-6 inline" id="telPhone">
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 ">真实姓名：</label>
												<div class="col-md-6 inline" id="trueName" >
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 " >身份证号：</label>
												<div class="col-md-6 inline" id="identityCard">
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 ">邮箱：</label>
												<div class="col-md-6 inline" id="email">
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 " >通讯地址：</label>
												<div class="col-md-6 inline" id="address">
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 ">您的孩子多大?</label>
												<div class="col-md-6 inline" id="childAge">
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 ">您从什么渠道认知壹果的?</label>
												<div class="col-md-6 inline" id="fromChannel">
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 ">您代理壹果的经验或优势是什么?</label>
												<div class="col-md-6 inline" id="advantage">
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 ">您对壹果的意见或者建议(非必填)?</label>
												<div class="col-md-6 inline" id="suggest">
												</div>
												</div>
												<!-- <div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 ">分享比例：</label>
												<div class="col-md-6 inline">
												<input type="text" name="shareRate" class="form-control" style="width:100px" maxlength="2" onkeypress="return $.IsNum(event);" onblur="return $.IsNaN(this);" placeholder="不输入视为0">
												</div>
												</div>
												<div class="form-group  mrg-bt10">
												<label class="control-label col-md-4 ">永久比例：</label>
												<div class="col-md-6 inline">
												<input type="text" name="foreverRate" class="form-control" style="width:100px"  maxlength="2" onkeypress="return $.IsNum(event);" onblur="return $.IsNaN(this);" placeholder="不输入视为0">
												</div>
												</div> -->
																					
											
										</div>
									</div>
									
									
									<div class="box " >
										<div class="box-title" style="border-bottom:1px solid #5e87b0">
											<h4><i class="fa fa-smile-o" style="color:#fcd76a"></i>审批意见</h4>
										</div>
										<div class="box-body">
											<textarea name="checkRemark" placeholder="请输入审批意见" class="form-control" style="width:480px;resize:none;" ></textarea>
										</div>
									</div>
									<div class="box div_yijian" style="display:none">
					 					<button type="button" class="btn btn-danger" style="width:80px;" status="Reject">拒绝</button>
										<button type="button" class="btn btn-success" style="width:80px;" status="Pass">通过</button>
									</div>
							
								</div>
							</div>

							<!-- /SAMPLE -->

							<div class="footer-tools">
								<span class="go-top">
								<i class="fa fa-chevron-up"></i> Top
							</span>
							</div>
						</div>
						<!-- /CONTENT-->
					</div>
				</div>
			</div>
		</section>
		<!--/PAGE -->
		<!-- JAVASCRIPTS -->
		<!-- Placed at the end of the document so the pages load faster -->
		<!-- JQUERY -->
		<script src="../../js/jquery/jquery-2.0.3.min.js"></script>
		<script type="text/javascript" src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>
		<!-- BOOTSTRAP -->
		<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>
			<!--bootbox-->
		<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
		<!-- COOKIE -->
		<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
		<!-- CUSTOM SCRIPT -->
		<script src="../../js/script.js"></script>
		<script src="../../js/common.js"></script>

		<script>
			var AddDetail = function() {
				var id,userId,openId,userName;
			    
				
				var getDetail = function() {
					$.ajax({
						type: "get",
						url: App.getContextPath() + "admin/agent/getAgent.do",
						data: {
							id:id
						},
						async: true,
						success: function(result) {
						if(result!=null){
							userId=result.userId;	
							 openId=result.ygUser.openId
							 userName=result.telPhone;
							 
						   $("#telPhone").html(result.telPhone);					  
						   
						   $("#createTime").html($.getLocalTime(result.createTime));
						   $("#trueName").html(result.trueName);
						   $("#telPhone").html(result.telPhone);
						   $("#address").html(result.address);
						   $("#identityCard").html(result.identityCard);
						   $("#email").html(result.email);
						   $("#childAge").html(result.childAge);
						   $("#fromChannel").html(result.fromChannel);
						   $("#advantage").html(result.advantage);
						   $("#suggest").html(result.suggest);
						  
						   var status="待审批";
						   if(result.checkStatus=="Pass")status="审批通过";
						   if(result.checkStatus=="Reject")status="审批未通过";						   
						   $("#checkStatus").html(status);	
						   
						   if(result.checkStatus=="Waiting"){
							   $(".div_yijian").show();	
							   $(".div_result").hide();	
							   $("[name=shareRate]").val(10);
							   $("[name=foreverRate]").val(10);
						   }else{
							   $("#checkTime").html($.getLocalTime(result.checkTime));	
							   $("#checkBy").html(result.checkBy);
							   $("[name=shareRate]").val(parseInt(result.ygUser.shareRate*100));
							   $("[name=foreverRate]").val(parseInt(result.ygUser.foreverRate*100));
							   $(".div_result").show();			
							   $("input").attr("readOnly","readOnly");
							   $("textarea").text(result.checkRemark);
							   $("textarea").attr("readOnly","readOnly");
						   }
							  
						  
						}
						}
					});
				};
				var updateStatus=function(){
					var remark=$("[name=checkRemark]").val();
					var status=$(this).attr("status");
					var isPass=status=="Reject"?false:true;
					
					if(remark==""&&!isPass){
						$.alert("请输入审批意见");
						return false;
					}
					 $.confirm("确认审核操作?",function(){
						 $.blockUI();
						 $.ajax({
								type: "get",
								url: App.getContextPath() + "admin/agent/updateCheckStatus.do",
								data: {id: id,checkStatus:status,checkRemark:remark,userId:userId,shareRate:$("[name=shareRate]").val(),foreverRate:$("[name=foreverRate]").val(),openId:openId,userName:userName},
								async: true,
								success: function(result) {
									$.unblockUI();
									if(result.type=="error"){
										$.alert(result.extra);								
									}else{
										$.alert("审核成功");
										window.location.href="agent_list.html";
									}						
								}
							});
					
					
					});
				}
				
				
				return {
					init: function() {
						App.init();
						id=$.getUrlParam("id");						
						getDetail();
						$(".btn-danger,.btn-success").click(updateStatus);
					}
				}
			}();
			$(function() {
				$("#header").load("../head.html");
				///$("#sidebar").load("../menu.html");
				AddDetail.init();
			});
		</script>

		<!-- /JAVASCRIPTS -->
	</body>

</html>